<?php
$this->breadcrumbs=array(
	'综合控制台'=>array($this->pre_module_url.'/index/index'),
	'产品管理'=>array($this->pre_module_url.'/productSale/admin'),
	'发布宝贝'=>array($this->pre_module_url.'/productCreateA/create/step/1'),
);
//默认行业分类
$default_category_id = isset($remember_cateid)?$remember_cateid:102;
$default_category = Category::model()->findByPk($default_category_id);
//顶级ID
$cate_top = ($default_category->zca_level==1)?$default_category->zca_id:(($default_category->zca_level==2)?$default_category->zca_parentid:$default_category->zca_topid);
//父级
$cate_parent = ($default_category->zca_level==1)?"0":(($default_category->zca_level==2)?$default_category->zca_id:$default_category->zca_parentid);
//三级
$cate_three = ($default_category->zca_level==3)?$default_category->zca_id:"0";
?>
<div class="hr_15"></div>
<!--发布宝贝 start-->
<div class="selling">
	<div class="hd c_f">
		<h2 class="fs_14 c_666 f_l">选择产品类目</h2>
		<div class="note f_r mr20"><span class="mem_ico"></span>没有找到相应的类别？<a class="c_06c" href="javascript:"</a><?php echo CHtml::link('去类目管理',array($this->pre_module_url.'/category/admin'),array('class'=>'c_06c','target'=>'_blank'))?></div>
	</div>
	<?php $form=$this->beginWidget('CActiveForm', array(
		'method'=>'get',
	)); ?>
	<div class="pro_filter c_f filter">
			<label class="mr10">类目搜索:</label>
			<?php echo CHtml::textField('zam_title',isset($model)?$model->zca_title:"",array('class'=>'t_ipt w_120')); ?>
			<?php echo CHtml::submitButton(Yii::t('cmp','Search')."类目",array('class'=>'mem_btn mem_btn17'))?>
	</div>

	<div class="bd" id="productCategory">
		<div>
			<!-- 提交搜索时，显示搜索内容 -->
			<?php if(isset($model)){ ?>
				<div class="categ_tip ff_s mt10>
					<span class="ml40">匹配到 <?php echo $model->search()->getItemCount()?> 个类目</span>
					<span class="f_r"><?php echo CHtml::link(' X 关闭,返回选择类目',isset($_GET['id'])?array($this->pre_module_url.'/productCreate/update/id/'.$_GET['id'].'/step/1'):array($this->pre_module_url.'/productCreate/create/step/1'),array('class'=>'c_06c'))?></span>
				</div>
				<?php $this->widget('zii.widgets.CListView', array(
					'dataProvider'=>$model->search(),
					'template'=>'{items}',
					'itemView'=>'_view_category',
					'tagName'=>'select',
					'htmlOptions'=>array(
										'size'=>'12',
										'class'=>'w_500 mt10',
										'name'=>'cateid3',
									),
				)); ?>
			<?php }else{ ?>
			<!-- 显示行业分类列表 -->
				<span id="catagory" >
					<select name="cateid1" size="12" class="level_1 w_210 mr10" id="dataProductIndustryId1" ></select>
					<select name="cateid2" size="12" class="level_2 w_210 mr10" id="dataProductIndustryId2"></select>
					<select name="cateid3" size="12" class="level_3 w_210 mr10" id="dataProductIndustryId3" ></select>
				</span>
			<?php } ?>
		</div>
		<div class="categ_tip ff_s mt10">
			 您当前选择的类目：<span class="fw_b c_f60 cate_notice"><em id="class1"></em><em id="class2"></em><em id="class3"></em></span>
		</div>
		<div class="t_c fs_14">
			<?php echo CHtml::submitButton('下一步，填写产品信息',array('class'=>'mem_btn mem_btn12','name'=>'next'))?>
		</div>
	</div>
	<?php $this->endWidget(); ?>
</div>
<!--发布宝贝 end-->  
<script type="text/javascript" src="/js/jquery-ui-1.9.2.custom.js"></script>
<script type="text/javascript" src="/js/jquery.ui.widget.js"></script>
<script type="text/javascript" src="/js/multi_select.js"></script>
<script type="text/javascript">
$.getJSON('/cache/getcategory',function(json){
	var options	= {data	: json};
	var loc = new multi_select(options);
	loc.bind('#catagory .level_1',<?php echo $cate_top ?>);
	loc.bind('#catagory .level_2',<?php echo $cate_parent ?>);
	loc.bind('#catagory .level_3',<?php echo $cate_three ?>);
	var sel= $("#catagory .level_1 .default").text();	
	$("#class1").html(sel);
	var sel2= $("#catagory .level_2 .default").text();
	$("#class2").html(" > "+sel2);
	var sel3= $("#catagory .level_3 .default").text();
	$("#class3").html(" > "+sel3);
});
</script>
<script>
//选择分类的时候触发，更新当前选择类目
$("#dataProductIndustryId1").bind('change', function() {	
    var sel= $("#dataProductIndustryId1 option:selected").text();	
		$("#class1").html(sel);
    var sel= $("#dataProductIndustryId2 option:selected").text();
		$("#class2").html(' > '+'请选择');
    var sel= $("#dataProductIndustryId3 option:selected").text();
		$("#class3").html('');
});
$("#dataProductIndustryId2").bind('change', function() {	
   	var sel= $("#dataProductIndustryId2 option:selected").text();	
		$("#class2").html(" > "+sel);
    var sel= $("#dataProductIndustryId3 option:selected").text();
		$("#class3").html("");
});	
$("#dataProductIndustryId3").bind('change', function() {	
    var sel= $("#dataProductIndustryId3 option:selected").text();
		$("#class3").html(" > "+sel);
});		

<?php if(isset($model)){ ?>
//查找的时候，选择筛选结果，  更新当前选择类目
$('#yw1').bind('change',function(){
	$('.cate_notice').html($('#yw1 option:selected').html());
});
<?php }?>
</script>


